package com.lwj.project1.PersonActivity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.lwj.project1.R;
import com.lwj.project1.databaseHelper.ImageUtil;
import com.lwj.project1.databaseHelper.MySqliteOpenHelper;
import com.lwj.project1.entity.User;

public class ShowPersonInfoActivity extends AppCompatActivity {

    private ImageView showHead;
    private TextView showUserName;
    private TextView showPhone;
    private TextView showEmail;
    private TextView showSex;
    private TextView showLocation;
    private TextView showDescription;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_show_person_info);
        showHead = findViewById(R.id.show_head);
        showUserName = findViewById(R.id.show_username);
        showPhone = findViewById(R.id.show_phone);
        showEmail = findViewById(R.id.show_email);
        showSex = findViewById(R.id.show_sex);
        showLocation = findViewById(R.id.show_location);
        showDescription = findViewById(R.id.show_description);
        MySqliteOpenHelper mySqliteOpenHelper = new MySqliteOpenHelper(getApplicationContext());
        SharedPreferences sharedPreferences = getSharedPreferences("project_content",MODE_PRIVATE);
        User user = mySqliteOpenHelper.findUserByName(sharedPreferences.getString("username",""));
        if (user == null)return;
        if (user.getHeadImgStr() != null)showHead.setImageBitmap(ImageUtil.base64ToImage(user.getHeadImgStr()));
        showUserName.setText(user.getUserName());
        showPhone.setText(user.getPhone());
        showEmail.setText(user.getEmail());
        showSex.setText(user.getGender());
        showLocation.setText(sharedPreferences.getString("location",""));
        showDescription.setText(user.getDescription());
    }
}